package com.betty.cscams.config;

import com.betty.cscams.constant.SysConstants;
import org.apache.commons.lang3.SystemUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


@Configuration
public class WebMvcConfig extends  WebMvcConfigurerAdapter{
        /**
         * 这里是映射文件路径的方法
         */
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
            //根据系统类型判断文件存储路径
            String mImagesPath =SystemUtils.IS_OS_LINUX ? SysConstants.IMG_LINUX_PATH : SysConstants.IMG_WINDOWS_PATH;
            registry.addResourceHandler("/img/**").addResourceLocations(mImagesPath);
            super.addResourceHandlers(registry);
        }

}
